<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <ul>
        <li v-for="item in comArr" :key="item">{{item.todo}}</li>
      </ul>
    </div>
  </body>
</html>
<script src="http://chst.vip:8081/vue.js"></script>
<script>
  // v-if和v-for优先级 源码在判断优先级的顺序上 v-for的render的函数要先执行 后执行v-if的判断

  //   永远不要把v-for和v-if放在同一个元素上

  const vm = new Vue({
    el: "#app",
    computed: {
      comArr() {
        return this.arr.filter((item) => item.isComplete);
      },
    },
    data: {
      arr: [
        { id: 1, todo: "写代码", isComplete: true },
        { id: 2, todo: "改bug", isComplete: false },
        { id: 3, todo: "吃饭", isComplete: true },
      ],
    },
  });
</script>
